package com.asset.dispoal.business.mediation;

import com.asset.dispoal.business.mediation.api.CollectionRecordService;
import com.asset.dispoal.business.mediation.dto.CollectionRecordResponse;
import com.asset.dispoal.business.mediation.dto.QueryCollectionRecordRequest;
import com.asset.dispoal.business.mediation.dto.SaveCollectionRecordRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.core.util.StringUtil;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @description:
 * @author: yf
 * @date: 2022-09-13 10:35:48
 */
@Slf4j
@RestController
@RequestMapping("business/collect")
@Api(value = "催记接口管理", tags = "催记管理")
public class CollectionRecordController {
    @Autowired
    private CollectionRecordService recordService;

    @PostMapping("save")
    @ApiOperation(value = "催收记录保存接口", notes = "催收记录保存")
    public Result save(@RequestBody SaveCollectionRecordRequest request) {
        return recordService.save(request);
    }

    @PostMapping("list")
    @ApiOperation(value = "催收记录列表接口", notes = "催收记录列表")
    public Result<PageVO<CollectionRecordResponse>> save(@RequestBody QueryCollectionRecordRequest request) {
        if (StringUtil.isBlank(request.getCaseId())) {
            return Result.faild("案件id不能为空");
        }
        return recordService.query(request);
    }

}
